import logging

import requests
import re
import os
import base64
from selenium import webdriver
from time import sleep
logging.basicConfig(level=logging.DEBUG,
                    format="%(asctime)s %(name)s %(levelname)s %(message)s",
                    datefmt='%Y-%m-%d  %H:%M:%S %a')  # 注意月份和天数不要搞乱了，这里的格式化符与time模块相同
def get_cookie(url):
    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument('--headless')
    chrome_options.add_argument('--disable-gpu')
    browser = webdriver.Chrome(chrome_options=chrome_options, executable_path="D:\program\chromedriver.exe")
    browser.get(url)
    sleep(5)

    cookie = browser.execute_script('return document.cookie')
    logging.info("获取的cookie为 : "+cookie)
    return cookie

# print(get_cookie('http://www.netbian.com'))
# sleep(1505)
